<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>PCMS内容管理系统</title>
<link href="<?php echo $_tpl['css']; ?>admin.css" rel="stylesheet" type="text/css" />
<script language="javascript" src="<?php echo $_tpl['js']; ?>jquery.js"></script>
<script language="javascript" src="<?php echo $_tpl['js']; ?>cookie.js"></script>
<script language="javascript">

function del( cname, id ){
	var del = window.confirm("确定要删除'"+cname+"'栏目吗?");
	if (del) {
		return true;
	}
	else
	{
		return false;
	}
}

//收缩、展开栏目
function hiddenorshow( cate )
{
	var cate2 = '#s'+cate;
	var hiddenarry = new Array();
	var html = $( cate2 ).html();
	if ( html == '&nbsp;-&nbsp;&nbsp;' )
	{
		hidden( cate,hiddenarry );
		$( cate2 ).html('&nbsp;+&nbsp;&nbsp;');
	}
	else
	{
		show( cate,hiddenarry );
		$( cate2 ).html('&nbsp;-&nbsp;&nbsp;');
	}
}

//收缩栏目
function hidden( cate,hiddenarry ){

	var cate1 = '#'+cate;
	var cate1id = $(cate1).attr( "id" );
	var name1 = $(cate1).attr( "name" );
	var name = $(cate1).next().attr( "name" );
	var id = $(cate1).next().attr( "id" );
	var lengh = hiddenarry.length;

	flag = true;
	flag1 = false;
	for (i=0;i<lengh ;i++ )
	{
		if ( hiddenarry[i] == cate1id  )
		{
			flag= false;
		}
		if ( hiddenarry[i] ==name1 )
		{
			flag1 = true;
		}
	}
	if ( ( flag && flag1 ) || lengh==0  )
	{
		hiddenarry[lengh] = cate1id;
	}

	if ( name )
	{
		var cate2 =  '#'+id;

		for (i=0;i<hiddenarry.length ;i++ )
		{
			if ( hiddenarry[i] == name )
			{
				$(cate2). css( "display","none" );
			}
		}
		if ( name != 'cate0' )
		{
			hidden( id,hiddenarry );
		}

	}
}

//展开栏目
function show( cate,hiddenarry ){

	var cate1 = '#'+cate;
	var cate1id = $(cate1).attr( "id" );
	var name1 = $(cate1).attr( "name" );
	var name = $(cate1).next().attr( "name" );
	var id = $(cate1).next().attr( "id" );
	var lengh = hiddenarry.length;

	flag = true;
	flag1 = false;
	for (i=0;i<lengh ;i++ )
	{
		if ( hiddenarry[i] == cate1id  )
		{
			flag= false;
		}
		if ( hiddenarry[i] ==name1 )
		{
			flag1 = true;
		}
	}
	if ( ( flag && flag1 ) || lengh==0  )
	{
		hiddenarry[lengh] = cate1id;
	}

	if ( name )
	{
		var cate2 =  '#'+id;

		for (i=0;i<hiddenarry.length ;i++ )
		{
			if ( hiddenarry[i] == name )
			{
				$(cate2). css( "display","" );
			}
		}
		if ( name != 'cate0' )
		{
			show( id,hiddenarry );
		}

	}
}


</script>
</head>
<body style='width:98%;'>
<table width="99%" border="0" align="center" cellpadding="5" cellspacing="1">
	<tr>
		<td height="20" colspan="4"><input class="btn2" type="button" onclick="window.location.href='add_column.php?reference=<?php echo $current_url; ?>';" value="添加" /></td>
	</tr>
	<tr>
		<td height="20" align="left" bgcolor="#000000"><span class="bold">ID</span></td>
		<td height="20" align="left" bgcolor="#000000"><span class="bold">栏目名称</span></td>
		<td height="20" align="left" bgcolor="#000000"><span class="bold">英文名称</span></td>
		<td height="20" align="left" bgcolor="#000000"><span class="bold">操作</span></td>
	</tr>
<?php
	foreach( $cateTree as $index => $value )
	{
		if ( $value['parent_id'] ==0 )
		{
			$bgcolor = '#323232';
		}
		else
		{
			$bgcolor = '#272727';
		}
?>
	<tr bgcolor="<?php echo $bgcolor; ?>" id="<?php echo 'cate'.$value['id']; ?>" name="<?php echo 'cate'.$value['parent_id']; ?>">
		<td height="20" width="10" align="center"><?php echo $value['id']; ?></td>
		<td height="20" align="left"><?php echo str_repeat( '&nbsp;&nbsp;', $value['level'] );?><span id="<?php echo 'scate'.$value['id']; ?>" style="cursor:pointer" onclick="hiddenorshow('<?php echo 'cate'.$value['id']; ?>')" width="10" name="span">&nbsp;-&nbsp;&nbsp;</span><?php echo $value['cname']; ?></td>
		<td height="20" align="left"><?php echo $value['ename']; ?></td>
		<td height="20" align="left"><a href="add_column.php?pid=<?php echo $value['id']; ?>">添加子栏目</a> <a href="set_column.php?id=<?php echo $value['id']; ?>">修改</a> <a href="del_column.php?id=<?php echo $value['id']; ?>" onclick="return del( '<?php echo $value['cname']; ?>', <?php echo $value['id']; ?> );">删除</a></td>
	</tr>
<?php
	}

?>
<?php
	if ( isset( $bar ) )
	{
?>
	<tr>
		<td height="20" colspan="4" align="center" bgcolor="#000000">
			<table width="30%"><tr align="center"><td><a href="<?php echo $bar['first_link']; ?>">首页</a></td><td><a href="<?php echo $bar['prev_link']; ?>">上一页</a></td><td><?php echo $bar['current']; ?> / <?php echo $bar['page']; ?></td><td><a href="<?php echo $bar['next_link']; ?>">下一页</a></td><td><a href="<?php echo $bar['last_link']; ?>">尾页</a></td></tr></table>
		</td>
	</tr>
<?php
	}
?>
</table>
</body>
</html>